package com.rjt.article.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.rjt.article.dto.ArticleVisitDto;
import com.rjt.article.model.ArticleVisitModel;

public interface ArticleVisitRepository extends JpaRepository<ArticleVisitModel, Integer> {
	
	
	@Query("select new com.rjt.article.dto.ArticleVisitDto(t.region,t.city,count(t.rId)) from ArticleVisitModel t where t.rId=:rId  GROUP BY t.region,t.city ")
	List<ArticleVisitDto> countByRIdAndArea(@Param(value = "rId") String rId);
	
	@Query("select new com.rjt.article.dto.ArticleVisitDto(DATE_FORMAT(createDate, '%Y-%m-%d'),count(t.rId)) from ArticleVisitModel t where t.rId=:rId  GROUP BY DATE_FORMAT(createDate, '%Y-%m-%d') ")
	List<ArticleVisitDto> countByRIdAndDate(@Param(value = "rId") String rId);
}
